const PostgresqlConnect = require('@src/db-server/db-connect/postgresql-connect')
const PostgresqlMigrate = require('@src/migrate/postgresql-migrate')
const BuildTable = require('@src/migrate/build-table')
/**
 * models生成表
 * @param {*} data 数据库配置对象
 * @param {*} models models配置，项目中的models/index.js中配置各模块
 */
function startAsyndb(data, models) {
  PostgresqlConnect(data).then(client => {
    PostgresqlMigrate.getAllTable(client).then(tableInfo => {
      BuildTable(tableInfo, models, client)
    })
  })
}

module.exports = startAsyndb

